<!DOCTYPE html>
<html lang="en">

<head>
    <title>项目跟踪</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/dist/plugins/select2/select2.min.css">
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=86e2297f">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=222aea35">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_855021_qg8ipx7k8ra.css">
</head>

<body>
    <section class="content" id="app">
        <div class="nav-tabs-custom oaReportNav">
            <ul class="nav nav-tabs pull-right" style="margin-bottom: 10px;height: 27px;">
                <template v-for="item,i in menuList">
                <li :class="i==selectedTab?'active':''"><a href="#sales-chart" data-toggle="tab" @click="switchTab(item.id,i, item.proSn)">{{item.projectName}}</a></li>
                </template>
                <!-- <button type="button" class="btn oaBtn pull-right btn-sm" v-if="!isLevel3 && authorityList['pmSponsor']" @click="addProject">新增项目</button>
                <button type="button" class="btn oaBtn pull-right btn-sm" v-if="isLevel3  && authorityList['pmSponsor']" @click="addThreeProject()">新增三级项目</button> -->
            </ul>
        </div>
        <div id="scrollDiv" v-if="emptyData" class="box-body no-padding" style="margin-top: 20px;position: relative;overflow: hidden;font-size: 40px;text-align: center">
        暂无数据
        </div>
        <div id="scrollDiv" v-if="!emptyData" class="box-body no-padding" style="position: relative;overflow: hidden">
            <div class="left-fixed">
                <table>
                    <tr v-if="!isLevel3">
                        <th style="width:169px">一级项目</th>
                        <th style="width:120px">二级项目</th>
                        <th style="width:70px">负责人</th>
                    </tr>
                    <tr v-if="isLevel3">
                        <th style="width:329px" colspan="2">三级项目</th>
                        <th style="width:70px">负责人</th>
                    </tr>
                </table>
            </div>
            <div class="left-fixed left-bottom-fixed">
                <table style="width:399px;border-right: 0;border-left: 0;margin-top: -1px">
                    <template v-for="item,i in projectList">
                        <template v-for="levelItem,li in item.level2" v-if="!isLevel3">
                            <tr>
                                <td style="width:168px;position: relative;" class="col-title project-name"  v-if="li == 0"
                                    :rowspan="item.level2Count" @click="loadTab(item)" @mouseenter="hoverProject(item)" @mouseleave="leaveProject(item)" :title="item.PRO_NAME">
                                    <span v-if="item.able && authorityList['pmSponsor']" style="position: absolute;top: 0;left: 5px;" @click="edit(item.ID)">编辑</span>
                                    <span v-if="item.able && authorityList['pmSponsor']" style="position: absolute;top: 0;right: 5px;" @click="projectFinish(item.PRO_SN)">完成</span>
                                    {{item.PRO_NAME}}
                                </td>
                                <td style="width:120px" class="enableClick project-name" @click="switchTab1(levelItem)" :title="levelItem.PRO_NAME">{{levelItem.PRO_NAME}}</td>
                                <!-- <td style="width:60px" class="enableClick" @click="viewTrackList(levelItem.ID,levelItem.PRO_PRINCIPAL_NAME,item.PRO_NAME+' - '+levelItem.PRO_NAME)">{{levelItem.PRO_PRINCIPAL_NAME}}</td> -->
                                <td style="width:70px" class="enableClick" @click="viewTrackList1(item,levelItem)">{{levelItem.PRO_PRINCIPAL_NAME}}</td>
                            </tr>
                            <tr v-if="levelItem.expand"><td colspan="3" style="height: 130px;" :data-id="levelItem.ID"></td></tr>
                        </template>
                        <tr v-if="!isLevel3">
                            <td colspan="3" v-if="i < projectList.length-1 " style="height:10px;border-right: 0;border-left: 0"></td>
                        </tr>

                        <tr v-if="isLevel3">
                            <td class="levele3-1">
                                <i class="top-right" v-if="item.hasAttach || item.REMARKS!=''"></i>
                                <span class="annex" @click="annexEdit(item.ID)">附件</span>
                            </td>
                            <td style="width:288px;text-align:left;padding-left: 3px;position: relative;":title="item.PRO_NAME">
                                <span class="project-name">{{item.PRO_NAME}}</span>
                                <div class="tip-box" @click=""><i class="up-arrow"></i>{{item.PRO_NAME}}</div>
                            </td>
                            <td style="width:70px" class="enableClick"  @click="viewTrackList2(item)"><span class="enableClick" >{{item.PRO_PRINCIPAL_NAME}}</span><span :class="item.expand?'iconfont icon-shouqi':'iconfont icon-zhankai'"></span></td>
                        </tr>
                        <tr v-if="isLevel3 && item.expand"><td colspan="3" style="height: 130px;" :data-id="item.ID"></td></tr>
                    </template>
                </table>
            </div>
            <div class="top-fixed">
                <div class="iconfont icon-zuojiantou" title="时间回退一周" :style="positionMoveUp==0?'opacity: 0':''" @mouseenter="function(){positionMoveUp = 1}" @mouseleave="function(){positionMoveUp = 0}"  @click="positionDate()"></div>
                <table style="width:1200px;border-left: 0">
                    <tr>
                        <th v-for="item,i in monthList" :colspan="item.length" :class="i%2 == 0 ? 'bk' : ''" :title="monthFormat(i)+'月'" >{{monthFormat(i)}}月</th>
                    </tr>
                    <tr>
                    <template v-for="item,i in monthList">
                        <th v-for="month,ni in item" :class="i%2 == 0 ? 'bk' : ''">{{month.day}}</th>
                    </template>
                    </tr>
                </table>
            </div>
            <div class="right-scroll">
                <table style="width:1200px;margin: 39px 0px 0px 399px;border-left: 0">
                <template v-for="item,i in projectList">
                    <template  v-for="levelItem,i in item.level2" v-if="!isLevel3">
                        <tr class="row-plan">
                            <template v-for="monthList,li in monthList">
                                <td v-for="monthItem,i in monthList">
                                    <div @click="addPlan(item , levelItem , monthItem.date)" :class="currentUser.id==levelItem.PRO_PRINCIPAL && levelItem.IS_PLAN == 0 && dateCompare(today,monthItem.date)? 'rs-enable ' : ''" v-if="planList[levelItem.ID + monthItem.date]">-</div>
                                    <div @click="addPlan(item , levelItem , monthItem.date)" :class="currentUser.id==levelItem.PRO_PRINCIPAL && levelItem.IS_PLAN == 0 && dateCompare(today,monthItem.date)? 'rs-enable ' : ''" v-if="!planList[levelItem.ID + monthItem.date]"></div>
                                </td>
                            </template>
                        </tr>

                        <tr class="row-track">
                            <template v-for="monthList,li in monthList">
                                <td v-for="monthItem,i in monthList">
                                    <div @click="addTrack(levelItem.ID , monthItem.date , levelItem.PRO_PRINCIPAL)" :class="monthItem.date==today && currentUser.id==levelItem.PRO_PRINCIPAL && levelItem.IS_PLAN == 1 && dateCompare(levelItem.MIN_PLAN_DATE,today) ? 'selected' : ''" v-if="trackList[levelItem.ID + monthItem.date]">√</div>
                                    <div @click="addTrack(levelItem.ID , monthItem.date , levelItem.PRO_PRINCIPAL)" :class="monthItem.date==today && currentUser.id==levelItem.PRO_PRINCIPAL && levelItem.IS_PLAN == 1 && dateCompare(levelItem.MIN_PLAN_DATE,today) ? 'selected' : ''" v-if="!trackList[levelItem.ID+monthItem.date]"></div>
                                </td>
                            </template>
                        </tr>
                        <tr v-if="levelItem.expand">
                            <td colspan="60" :data-id="'pp'+levelItem.ID">
                                <div class="track-list">
                                    <div class="track-title"><span class="participant" :title="levelItem.principals">参与人：{{levelItem.principals.length==0?"未填写":""}}{{levelItem.principals}}</span> <span>开始日期：{{levelItem.planDate.sDate==""?"未填写":levelItem.planDate.sDate}}</span> <span>结束日期：{{levelItem.planDate.eDate==""?"未填写":levelItem.planDate.eDate}}</span></div>
                                    <div class="list-content" v-for="trackIt in levelItem.trackList">
                                        <span class="trakc-date">{{trackIt.TRACK_DATE}}</span>
                                        <p class="project-content">{{trackIt.TRACK_CONTENT}}</p>
                                    </div>
                                    <div style="text-align: center;font-size: 30px" v-if="levelItem.trackList.length == 0">暂无跟踪数据</div>
                                </div>
                            </td>
                        </tr>
                    </template>
                    <tr v-if="!isLevel3">
                        <td colspan="60" v-if="i < projectList.length-1 " style="height:10px"></td>
                    </tr>

                    <template v-if="isLevel3">
                        <tr class="row-plan">
                        <template v-for="monthList,li in monthList">
                            <td v-for="monthItem,i in monthList">
                                <div @click="addPlan(item , item , monthItem.date)" :class="currentUser.id==item.PRO_PRINCIPAL && item.IS_PLAN == 0 && dateCompare(today,monthItem.date)? 'rs-enable ' : ''" v-if="planList[item.ID + monthItem.date]">-</div>
                                <div @click="addPlan(item , item , monthItem.date)" :class="currentUser.id==item.PRO_PRINCIPAL && item.IS_PLAN == 0 && dateCompare(today,monthItem.date)? 'rs-enable ' : ''" v-if="!planList[item.ID + monthItem.date]"></div>
                            </td>
                        </template>
                        </tr>
                        <tr class="row-track">
                            <template v-for="monthList,li in monthList">
                                <td v-for="monthItem,i in monthList">
                                    <div @click="addTrack(item.ID , monthItem.date , item.PRO_PRINCIPAL)" :class="monthItem.date==today && currentUser.id==item.PRO_PRINCIPAL && item.IS_PLAN == 1 && dateCompare(item.MIN_PLAN_DATE,today) ? 'selected' : ''" v-if="trackList[item.ID + monthItem.date]">√</div>
                                    <div @click="addTrack(item.ID , monthItem.date , item.PRO_PRINCIPAL)" :class="monthItem.date==today && currentUser.id==item.PRO_PRINCIPAL && item.IS_PLAN == 1 && dateCompare(item.MIN_PLAN_DATE,today) ? 'selected' : ''" v-if="!trackList[item.ID + monthItem.date]"></div>
                                </td>
                            </template>
                        </tr>
                        <tr v-if="item.expand">
                            <td colspan="60" :data-id="'pp'+item.ID">
                                <div class="track-list">
                                    <div class="track-title"> <span>开始日期：{{item.planDate.sDate==""?"未填写":item.planDate.sDate}}</span> <span>结束日期：{{item.planDate.eDate==""?"未填写":item.planDate.eDate}}</span></div>
                                    <div class="list-content" v-for="trackIt in item.trackList">
                                        <span class="trakc-date">{{trackIt.TRACK_DATE}}</span>
                                        <p class="project-content">{{trackIt.TRACK_CONTENT}}</p>
                                    </div>
                                    <div style="text-align: center;font-size: 30px" v-if="item.trackList.length == 0">暂无跟踪数据</div>
                                </div>
                            </td>
                        </tr>
                    </template>
                </template>
                </table>
            </div>
        </div>
    </section>
    <script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
    <!--插件JS-->
    <script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
    <!--框架已定义 JS-->
    <script src="/dist/js/app_iframe.js?t=8e743a31"></script>
    <!--oa自定义  JS-->
    <script src="/dist/js/oa.js?t=54c6b89c"></script>
    <script src="https://file.ggxqce.com/web/vue.min.js"></script>
    <script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
    <script type="text/javascript" src="/dist/plugins/select2/select2.full.min.js"></script>
    <style type="text/css">
    .top-right{
        width: 0;
        height: 0;
        border-top: 10px solid red;
        border-left: 10px solid transparent;
        position: absolute;
        top: 0;
        right: 0;
    }
    .left-fixed,.top-fixed{
        position: absolute;background-color: #fff;
    }
    .left-fixed{
        width: 400px;
        overflow: hidden;
        border-bottom: 1px solid #ddd;
    }
    .left-bottom-fixed{
        margin-top:41px;height: 443px;border-left: 1px solid #ddd;
    }
    .left-bottom-fixed .levele3-1{
        width: 39px;
        position: relative;
    }
    .left-bottom-fixed .levele3-1 .annex{
        cursor: pointer;
        color: blue;
        text-decoration-line: underline;
    }
    .left-bottom-fixed .col-title{
        cursor: pointer;
    }

    .left-bottom-fixed .col-title span{
        /*border:1px solid #ddd;*/
        border-radius: 4px;
        padding: 1px 5px;
        margin-top: 5px;
        color: blue;
        text-decoration-line: underline;

    }
    .left-bottom-fixed .project-name{
        overflow:hidden; 
        text-overflow:ellipsis;
        display:-webkit-box; 
        -webkit-box-orient:vertical;
        -webkit-line-clamp:2; 
    }

    .tip-box{
        background-color:#d3e8fd;position: absolute;width: 288px;left: 0;top: 38px;padding: 5px;z-index: 1;
        display: none;
    }
    .tip-box .up-arrow{
        display: inline-block;
        background: #fff;
        position: absolute;
        top: -5px;
        left: 40px;
        border-width: 0 6px 5px;
        border-style: solid;
        border-color: transparent transparent #d3e8fd;
    }
    .left-fixed td,.left-fixed th{
        height: 40px;
        border: 1px solid #ddd;
        text-align: center;
        border-top: 0;
        border-left: 0;
    }
    .left-fixed th{
        background-color: yellow;
    }

    .top-fixed{
        width: 907px;left: 400px;overflow: hidden;
    }
    .top-fixed th{
        height: 20px;
        text-align: center;
        border: 1px solid #ddd;
        background: yellow;
        border-left: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .top-fixed .bk,.right-scroll .bk{
        background-color: #ffffff;
    }

    .right-scroll{
        height: 500px;border:1px solid #ddd;overflow: scroll;
    }

    .right-scroll .track-list{
        min-height: 125px;margin: 2px;border:1px solid #ddd;text-align: left;
        width: 860px;
    }

    .right-scroll .track-list .track-title{
        text-align: right;
        background-color: #eee;
        padding-left: 5px;
        height: 25px;
        line-height: 25px;
        color: #999;

    }
    .right-scroll .track-list .track-title span{
        margin-right: 20px;
    }
    .right-scroll .track-list .track-title .participant{
        margin-right: 50px;
        float: left;
        width: 480px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: left;
    }

    .right-scroll .track-list .list-content{
        padding-left: 5px;
        display: inline-block;
    }

    .right-scroll .track-list .trakc-date{
        float: left;text-decoration-line: underline;margin-right: 10px;
        color: #999;
    }
    .right-scroll .track-list .project-content {
        float:left;width: 765px;margin: 0
    }

    .right-scroll td{
        border: 1px solid #ddd;
        text-align: center;
        height: 20px;
        border-left: 0;
        border-top: 0;
    }
    .right-scroll .row-plan{
        font-size: 20px;
        line-height: 19px;
    }
    .right-scroll .row-plan .rs-enable{
        cursor: pointer;
        /* border:1px solid #333; */
        height: 19px;
        line-height: 16px;
        width: 19px;
        box-shadow: inset 0px 0px 4px #333;
    }
    .right-scroll .row-plan .rs-enable:hover{
        border:1px solid #333;
        height: 19px;
        line-height: 15px;
        width: 19px;
    }
    .icon-zuojiantou{
        position: fixed;
        width: 29px;
        height: 29px;
        background-color: #fff;
        border-radius: 50px;
        color: blue;
        margin: 5px;
        text-align: center;
        line-height: 38px;
        font-size: 30px;
        cursor: pointer;
    }

    .right-scroll .row-track{
        font-size: 14px;
        line-height: 19px;
    }
    .right-scroll .row-track .selected{
        /* border:1px solid #333; */
        height: 19px;
        line-height: 19px;
        cursor: pointer;
        box-shadow: inset 0px 0px 4px #333;
    }
    .right-scroll .row-track .selected:hover{
        border:1px solid #333; 
    }

    .enableClick{
        color: blue;
        text-decoration-line: underline;
        cursor: pointer;
    }

    .icon-zhankai,.icon-shouqi{
        float: right;
        margin-top: -2px;
        color: blue;
    }

    .ui_title{
        background: #fff;
        border: 0
    }
    .ui_dialog,.ui_border{border: 0}
    </style>
    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: {
                currentUser: getCurrentUser(),
                monthList:{},
                planList:{},
                trackList:{},
                projectList:[],
                today:"",
                menuList:[],
                mainId:"",
                selectedProjectId:"",
                selectedTab:0,
                selectedProSn:"",
                isLevel3:false,
                emptyData:false,
                authorityList:{pmSponsor:false,pmSuper:false},
                positionVal: 0,
                positionMoveUp:0
            },
            methods: {
                refresh: function () {
                    var that = this;

                    //权限
                    $.wyui.postMethod(urlConfig.system.rightOp.getRightOpByUserId, {userId: currentUser.id}, function (data) {
                        for (var i = 0; i < data.length; i++) {
                            that.authorityList[data[i].eName] = true;
                        }
                    },true);

//                    that.monthList = {};
                    that.planList={};
                    that.trackList={};
                    that.projectList=[];

                    $.wyui.postMethod(urlConfig.pm.projectTrack.getLevel2ByLevel1Id, {projectId: that.mainId}, function (data) {
                        that.menuList = [];
                        data.projectList.forEach(element => {
                            var o = new Object();
                            o.projectName = element.PRO_NAME;
                            o.id = element.ID;
                            o.proSn = element.PRO_SN;
                            that.menuList.push(o);
                        });
                    });

                    $.wyui.postMethod(urlConfig.pm.projectTrack.getProjectTrackInfo, {
                        level:!that.isLevel3 ? 2 : 3,
                        projectId:that.selectedProjectId,
                        userId: that.authorityList["pmSuper"] ? "" : currentUser.id,
                        positionVal: that.positionVal
                    }, function (data) {
                        if(data.projectList.length>0  && !that.isLevel3){
                            data.projectList.forEach(element => {
                                element.able = false;
                                element.level2.forEach(element1 => {
                                    element1.expand = false;
                                    element1.trackList = [];
                                    element1.principals = "";
                                    element1.planDate = {};
                                    element.level2Count = element.level2.length;
                                });
                            });
                        }
                        if(data.projectList.length>0  && that.isLevel3){
                            data.projectList.forEach(element => {
                                element.expand = false;
                                element.trackList = [];
                                element.principals = "";
                                element.planDate = {};
                            });
                        }
                        that.monthList = data.monthList;
                        that.projectList = data.projectList;
                        that.planList = data.planList;
                        that.trackList = data.trackList;
                        that.today = data.today;

                        
                        if(data.projectList.length>0){
                            that.emptyData=false;
                        }else
                            that.emptyData=true;
                        
                        setTimeout(function () {
                            initEvent();
                        }, 300);
                    });
                },
                positionDate:function(){
                    this.positionVal += 1;
                    this.refresh();
                },
                monthFormat:function(month){
                    if(month.substring(0,1) == "0")
                        return month.substring(1,2);
                    else
                        return month;
                },
                dateCompare:function (minDate , maxDate) {
                    if(minDate == undefined || maxDate == undefined || new Date(minDate)>new Date(maxDate))
                        return false;
                    else
                        return true;
                },
                hoverProject:function(item) {
                    item.able = true;
                },
                leaveProject :function (item) {
                    item.able = false;
                },
                projectFinish:function (projectSn) {
                    var that =this;
                    if(confirm("确定已经完成该项目？")){
                        $.wyui.postMethod(urlConfig.pm.projectTrack.setProjectFinish, {
                            projectSn:projectSn
                        }, function (data) {
                            that.refresh();
                        });
                    }
                },
                edit:function (projectId) {
                    $.dialog({
                        content: 'url:addProject.html?projectId='+projectId,
                        title: '',//修改项目
                        width: 810,
                        height: 300,
                        max: false,
                        min: false,
                        lock: true
                    });
                },
                loadTab:function(item){
                    var that =this;
                    that.menuList = [];
                    $(".pull-right li").attr("class","");
                    $(".pull-right li").eq(0).attr("class","active");
                    item.level2.forEach(element => {
                        var o = new Object();
                        o.projectName = element.PRO_NAME;
                        o.id = element.ID;
                        o.proSn = element.PRO_SN;
                        that.menuList.push(o);
                    });
                },
                switchTab1:function(level2Item){
                    var that = this;
                    top.closeTabByPageId("addProject");
                    top.addTabs({
                        id: 'addProject',
                        title: level2Item.PRO_NAME,
                        close: true,
                        url: '/pm/list.html?projectId=' + level2Item.ID +'&level=true&proSn='+level2Item.PRO_SN
                    });
                },

                switchTab:function(projectId, index, proSn){
                    var that = this;
                    $(".pull-right li").attr("class","");
                    $(".pull-right li").eq(index).attr("class","active");
                    $.wyui.page.urlParams.selectedTab = index;
                    this.isLevel3 = true;
                    this.selectedProjectId = projectId;
                    this.selectedProSn = proSn;
                    this.refresh();
                },
                viewTrackList:function(projectId,principalName,proName){
                    $.dialog({
                        content: 'url:trackList.html?projectId=' +projectId+'&principalName='+principalName+'&proName='+proName,
                        title: '',//跟踪列表
                        width: 890,
                        height: 350,
                        max: false,
                        min: false,
                        lock: true
                    });
                },
                viewTrackList1:function(item,level2Item){
                    var that = this;
                    var projectId = level2Item.ID;
                    if(level2Item.expand){
                        level2Item.expand = false;
                        item.level2Count = item.level2Count-1;
                    }
                    else{
                        level2Item.expand = true;
                        item.level2Count = item.level2Count+1;

                        $.wyui.postMethod(urlConfig.pm.projectTrack.getProjectTrack, {
                            projectId:projectId
                        }, function (data) {
                            level2Item.trackList = data.trackList;
                            level2Item.planDate = data.planDate;

                            level2Item.principals="";
                            data.principalList.forEach((ele,pi) =>{
                                level2Item.principals = level2Item.principals+ele.NAME+(data.principalList.length-1 ==pi?"":"、");
                            });
                            that.resiseHeight(projectId);
                        });
                        that.resiseHeight(projectId);
                    }
                },
                viewTrackList2:function(item){
                    var that = this;
                    var projectId = item.ID;
                    if(item.expand){
                        item.expand = false;
                    }
                    else{
                        item.expand = true;

                        $.wyui.postMethod(urlConfig.pm.projectTrack.getProjectTrack, {
                            projectId:projectId
                        }, function (data) {
                            item.trackList = data.trackList;
                            item.planDate = data.planDate;
                            item.principals="";
                            data.principalList.forEach((ele,pi) =>{
                                level2Item.principals = level2Item.principals+ele.NAME+(data.principalList.length-1 ==pi?"":"、");
                            });
                            that.resiseHeight(projectId);
                        });
                        that.resiseHeight(projectId);
                    }
                },
                resiseHeight:function (projectId) {
                    setTimeout(function () {
                        var height = $("td[data-id=" + "pp" + projectId + "]").height();
                        $(".left-bottom-fixed td[data-id=" + projectId + "]").height(height);
                    }, 10);
                },
                addProject:function(){
                    $.dialog({
                        content: 'url:addProject.html',
                        title: '',//新增项目
                        width: 810,
                        height: 300,
                        max: false,
                        min: false,
                        lock: true
                    });
                },
                addThreeProject:function(){
                    var that = this;
                    $.dialog({
                            content: 'url:addThreeProject.html?projectId='+that.selectedProjectId+'&proSn='+that.selectedProSn,
                            title: '',//新增三级项目
                            width: 600,
                            height: 190,
                            max: false,
                            min: false,
                            lock: true
                        });
                },
                annexEdit:function(productId){
                    var that = this;
                    $.dialog({
                            content: 'url:annexEdit.html?projectId='+productId,
                            title: '',//附件
                            width: 600,
                            height: 300,
                            max: false,
                            min: false,
                            lock: true
                        });
                },
                addPlan:function(proItem , level2Item , date){
                    if(level2Item.IS_PLAN == 1)
                        return false;
                    var id = level2Item.ID;
                    if(proItem.startPlanDate == undefined){
                        proItem.startPlanDate = date;
                        var strSDate = new Date(date).Format("yyyy-M-d");
                        this.$set(this.planList , id + strSDate, true);
                    }else{
                        var startPlanDate = new Date(proItem.startPlanDate);
                        var endPlanDate = new Date(date);
                        if(startPlanDate>endPlanDate){
                            var temp = startPlanDate;
                            startPlanDate = endPlanDate;
                            endPlanDate = temp;
                        }

                        level2Item.MIN_PLAN_DATE = new Date(startPlanDate).Format("yyyy-M-d");

                        var planList = new Array();
                        for(var i = 0;i < 60;i++){
                            var strSDate = startPlanDate.Format("yyyy-M-d");
                            var strEDate = endPlanDate.Format("yyyy-M-d");
                            var planObj = {"planDate":strSDate,"createUserId":currentUser.id};
                            var o = new Object();
                            o.planDate = strSDate;
                            o.createUserId = currentUser.id;
                            o.projectId = id;
                            planList.push(o);

                            this.$set(this.planList , id + strSDate, true);
                            if(strSDate == strEDate)
                                break;
                            startPlanDate.addDays(1);
                        }

                        $.wyui.postMethod(urlConfig.pm.projectTrack.batchAddPlan, {
                            planList:planList,
                            projectId: id,
                        }, function (data) {
                            level2Item.IS_PLAN = 1;
                        });
                    }
                },
                addTrack:function(projectId , trackDate , userId){
                    if(trackDate == this.today && userId == this.currentUser.id){
                        $.dialog({
                            content: 'url:trackDetail.html?projectId=' + projectId + "&trackDate=" + trackDate + "&t=" + new Date(),
                            title: '',//项目跟踪
                            width: 500,
                            height: 250,
                            max: false,
                            min: false,
                            lock: true
                        });
                    }
                },
                search: function () {
                    this.pageIndex = 1;
                    this.refresh();
                },
                pagination: function (auction) {
                    if (auction == "first")
                        this.pageIndex = 1;
                    else if (auction == "next" && this.pageIndex < this.pageCount)
                        this.pageIndex += 1;
                    else if (auction == "pre" && this.pageIndex > 1)
                        this.pageIndex -= 1;
                    else if (auction == "last")
                        this.pageIndex = this.pageCount;
                    this.refresh();
                }
            },
            mounted: function () {
                var that = this;
                
                var mainId = $.wyui.page.urlParams.mainId;
                that.mainId= mainId == undefined ? "" : mainId;
                var projectId = $.wyui.page.urlParams.projectId;
                that.selectedProjectId= projectId == undefined ? "" : projectId;
                var isLevel3 = $.wyui.page.urlParams.level;
                that.isLevel3 = isLevel3 == undefined ? false : true;
                var proSn = $.wyui.page.urlParams.proSn;
                that.selectedProSn = proSn == undefined ? "" : proSn;
                var selectedTab = $.wyui.page.urlParams.selectedTab;
                that.selectedTab = selectedTab == undefined ? "" : selectedTab;
                
                this.refresh();
            }
        });



    </script>
    <script type="text/javascript">
        $(function(){
            initEvent = function(){
                $(".right-scroll").on("scroll",function(){
                    $(".top-fixed").scrollLeft($(this).scrollLeft());
                    $(".left-fixed").scrollTop($(this).scrollTop());
                    resizeStyle();
                });

                $(".project-name").on("click",function(){
                    $(this).next().toggle();
                });
            }
            initEvent();

            var oldHeight = 0;
            resizeStyle = function (){
                var windowHeight = $(window).height();

                var rightWidth = $("#app").width();
                var scrollDivTop = $("#scrollDiv").offset().top;

                $(".left-bottom-fixed").height(windowHeight - scrollDivTop - 15 - 40 -17);
                $(".right-scroll").height(windowHeight - scrollDivTop - 15);
                $(".top-fixed").width(rightWidth - 400 -18);
                if(windowHeight < oldHeight)
                    $(".top-fixed").width(rightWidth - 401);
                oldHeight = windowHeight;
            }

            $(window).load(function(){
                resizeStyle();
                // setTimeout(function(){
                //     $(".right-scroll").scrollLeft(200);
                // },1000);
                
            });
            $(window).resize(function(){
                resizeStyle();
            });
        });
    </script>
</body>
</html>